import Http from "../../utils/HttpUtil";
import URL from "../URL";
export default{
    //二手交易列表
    async TransactionSelectSecondHandPayList(
        cashDepositStatus,
        insuranceStatus,
        aerocraftStatus,
        page=1
        ){
        let url=URL.GetURL(URL.TransactionSelectSecondHandPayList);
        return await(Http.Get(url+
            `?cashDepositStatus=${cashDepositStatus}
            &insuranceStatus=${insuranceStatus}
            &aerocraftStatus=${aerocraftStatus}
            &page=${page}`))
        .then(response=>{
            return(response);
        },reject=>{
            return Promise.reject(reject);
        });
    },
    //二手交易详情
    async TransactionSelectShopDetails(shopType,id){
        let url=URL.GetURL(URL.TransactionSelectShopDetails);
        return await(Http.Get(url+`?shopType=${shopType}&id=${id}`))
        .then(response=>{
            return(response);
        },reject=>{
            return Promise.reject(reject);
        });
    },

    //发布出租飞行器 添加
    async  TransactionAddSecondHand(
        type,//0 飞行器 1配件 2其他
        status, //0 发布 1修改
        id,//需要修改上的Id
        title,//标题
        describe,//商品描述不能为空
        aerocraftImgs,//无人机图片不能为空
        userId,//userId不能为空
        aerocraftBrand,//品牌不能为空
        aerocraftType,//飞机类型不能为空
        aerocraftModel,//型号不能为空
        aerocraftSn,//SN号不能为空
        insuranceStatus,//有无飞行器保险不能为空  //有无飞行器保险(0 有 1无)
        cashDeposit,//保证金不能为空
        cashDepositProportion,//保证金比例不能为空
        productService,//产品服务不能为空
        bargain,//是否议价 0一口价 1可议价
        bargainProportion,//议价比例
        insuranceDate,//保险有效期
        insuranceNumber,//保险单号
        insuranceCompany,//保险公司
        mail,//是否包邮 0是 1不是
        price,//价格
        cashPledge,//租赁押金
        insuranceImg,//保险单图片
    ){
        console.log(userId)
        let url=URL.GetURL(URL.TransactionAddSecondHand);
        let imgs=[
        ];
        //保险单图片
        if(insuranceImg!==undefined || insuranceImg===null || insuranceImg===""){
            imgs.push(['insuranceImg',insuranceImg])
        }
        //无人机图片不能为空
        if(aerocraftImgs!==undefined|| aerocraftImgs===null || aerocraftImgs===""){
            imgs.push(['aerocraftImgs',aerocraftImgs])
        }
        
        let data=[
            ["type",type],
            ["status",status],
            ["id",id],
            ["title",title],
            ["describe",describe],
            ["userId",userId],
            ["aerocraftBrand",aerocraftBrand],
            ["aerocraftType",aerocraftType],
            ["aerocraftModel",aerocraftModel],
            ["aerocraftSn",aerocraftSn],
            ["insuranceStatus",insuranceStatus],
            ["cashDeposit",cashDeposit],
            ["cashDepositProportion",cashDepositProportion],
            ["productService",productService],
            ["bargain",bargain],
            ["bargainProportion",bargainProportion],
            ["insuranceDate",insuranceDate],
            ["insuranceNumber",insuranceNumber],
            ["insuranceCompany",insuranceCompany],
            ["mail",mail],
            ["price",price],
            // ["cashPledge",cashPledge],
        ];
        
        return await(Http.PostWithFile(url,data,imgs))
        .then(response=>{
            return(response);
        },reject=>{
            return Promise.reject(reject);
        });
    },
}